#!/usr/bin/env bash

sudo apt-get update
sudo apt-get install -y docker.io
sudo docker pull centos
sudo docker pull shipyard/shipyard
sudo docker pull swarm
sudo docker pull shipyard/docker-proxy
sudo docker pull alpine
sudo docker pull microbox/etcd
sudo docker pull rethinkdb
sudo docker run -ti -d --restart=always --name shipyard-rethinkdb rethinkdb
sudo docker run -ti -d -p 4001:4001 -p 7001:7001 --restart=always --name shipyard-discovery microbox/etcd -name discovery
sudo docker run -ti -d -p 2375:2375 --hostname=$HOSTNAME --restart=always --name shipyard-proxy -v /var/run/docker.sock:/var/run/docker.sock -e PORT=2375 shipyard/docker-proxy
sudo docker run -ti -d --restart=always --name shipyard-swarm-manager swarm manage --host tcp://0.0.0.0:3375 etcd://10.0.2.15:4001
sudo docker run -ti -d --restart=always --name shipyard-swarm-agent swarm join --addr 10.0.2.15:2375 etcd://10.0.2.15:4001
sudo docker run -ti -d --restart=always --name shipyard-controller --link shipyard-rethinkdb:rethinkdb --link shipyard-swarm-manager:swarm -p 8083:8080 shipyard/shipyard server -d tcp://swarm:3375